﻿namespace Catel.Articles._08___WP7_Camera.Views
{
    using Phone.Controls;
    using Data;
    using Microsoft.Phone.Controls;
    using ViewModels;

    /// <summary>
    /// Interaction logic for PhotoView.xaml.
    /// </summary>
    public partial class PhotoView : PhotoViewIntermediate
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PhotoView"/> class.
        /// </summary>
        public PhotoView()
        {
            InitializeComponent();

            var gestureListener = GestureService.GetGestureListener(this);
            gestureListener.Flick += (sender, e) =>
            {
                if (ViewModel != null)
                {
                    ViewModel.Flick.Execute(new FlickData(e));
                }
            };
        }
    }

    /// <summary>
    /// Intermediate class for PhotoView since WP7 doesn't support generic base classes.
    /// </summary>
    public class PhotoViewIntermediate : PhoneApplicationPage<PhotoViewModel>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="PhotoViewIntermediate"/> class.
        /// </summary>
        /// <remarks>
        /// This constructor can only be used for design-time support. An exception will be thrown when it is used
        /// outside a designer.
        /// </remarks>
        public PhotoViewIntermediate()
        {
        }
    }
}
